from datetime import datetime

from pydantic import BaseModel, Field


class CodeSchema(BaseModel):
    code: str | None = None
    code_id: str | None = None
    status: int | None = None
    created_time: datetime | None = None
    activity_id: int | None = None
    prize_id: int | None = None


class CodeOutSchema(CodeSchema):
    id: int


class CodeBatchSchema(BaseModel):
    prefix: str = Field(max_length=32, description="前缀")
    begin_num: int = Field(description="开始码")
    end_num: int = Field(description="结束码")
    status: int = Field(0, description="状态")
    remark: str | None = Field(None, description="备注")
    export_num: int | None = Field(None, description="导出数量")


class CodeBatchOutSchema(CodeBatchSchema):
    id: int


class PrizeSchema(BaseModel):
    name: str | None = None
    short_name: str | None = None
    img: str | None = None
    num: int | None = None
    status: int | None = None


class PrizeOutSchema(PrizeSchema):
    id: int
    created_time: datetime | None = None
